package dhm.com.dhmshop.view.mine.myshop;

import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import java.util.HashMap;
import java.util.Map;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import dhm.com.dhmshop.R;
import dhm.com.dhmshop.base.BaseActiity;
import dhm.com.dhmshop.base.Presenter.PressenterImpl;
import dhm.com.dhmshop.base.netWork.Constant;
import dhm.com.dhmshop.base.netWork.LoginContract;
import dhm.com.dhmshop.entity.GetCash;
import dhm.com.dhmshop.utils.SpUtils;

public class CashdetailActivity extends BaseActiity implements LoginContract.IView {

    @BindView(R.id.name)
    TextView name;
    @BindView(R.id.moneys)
    TextView moneys;
    @BindView(R.id.creattime)
    TextView creattime;
    @BindView(R.id.two)
    RelativeLayout two;
    @BindView(R.id.passtime)
    TextView passtime;
    @BindView(R.id.three)
    RelativeLayout three;
    @BindView(R.id.add_time)
    TextView addTime;
    @BindView(R.id.money)
    TextView money;
    @BindView(R.id.pass_time)
    TextView passTimes;
    @BindView(R.id.account)
    TextView account;
    private String shop_id;
    private String cash_id;
    private PressenterImpl pressenter;
    private String uid;


    @Override
    protected int getLayout() {
        return R.layout.activity_cashdetail;
    }

    @Override
    protected void initView() {
        ButterKnife.bind(this);
        shop_id = getIntent().getStringExtra("shop_id");
        cash_id = getIntent().getStringExtra("cash_id");
        uid = SpUtils.getString(this, "uid");
        pressenter = new PressenterImpl();
        pressenter.attachView(this);
        Map<String,String> map=new HashMap<>();
        map.put("token",Constant.TOKEN);
        map.put("uid",uid);
        map.put("shop_id",shop_id);
        map.put("cash_id",cash_id);
        pressenter.sendMessage(this, Constant.GetCashInfo,map, GetCash.class);

    }

    @Override
    protected void initData() {

    }

    @OnClick(R.id.back)
    public void onViewClicked() {
        finish();
    }

    @Override
    public void requesta(Object data) {
        if (data instanceof GetCash){
            GetCash getCash= (GetCash) data;
            moneys.setText(getCash.getData().get(0).getMoney());
            money.setText(getCash.getData().get(0).getMoney());
            creattime.setText(getCash.getData().get(0).getAdd_time());
            addTime.setText(getCash.getData().get(0).getAdd_time());
            if (getCash.getData().get(0).getStatus()==1){
                three.setVisibility(View.GONE);
                passTimes.setText("处理中");
            }else if (getCash.getData().get(0).getStatus()==2){
                passtime.setText(getCash.getData().get(0).getPass_time());
                passTimes.setText(getCash.getData().get(0).getPass_time());
            }else if (getCash.getData().get(0).getStatus()==3){
                passTimes.setText("处理失败");
            }
            name.setText("提现 - 到支付宝"+getCash.getData().get(0).getAccount().substring(0,2)+"****"+getCash.getData().get(0).getAccount().substring(6,10));
            account.setText("支付宝"+getCash.getData().get(0).getAccount().substring(0,2)+"****"+getCash.getData().get(0).getAccount().substring(6,10));

        }

    }

    @Override
    public void fail(String error) {

    }
}
